﻿using System.Configuration;
  
namespace TWA.TFS
{
    /// <summary>
    /// Distribution group accessors for each project owner
    /// </summary>
    internal static class ProjectOwnerEmail
    {
        private static string Default
        {
            get
            {
                return ConfigurationManager.AppSettings ["InternalEmails"];
            }
        }

        private static string Project1
        {
            get
            {
                return ConfigurationManager.AppSettings ["Project1Owner"];
            }
        }

        private static string Project2
        {
            get
            {
                return ConfigurationManager.AppSettings ["Project2Owner"];
            }
        }

        private static string Project3
        {
            get
            {
                return ConfigurationManager.AppSettings ["Project3Owner"];
            }
        }

        internal static string CheckinAlerts
        {
            get { return Default; }
        }

        /// <summary>
        /// Evaluates the project name and area path to determine which project 
        /// owners should also be notified of the event.
        /// </summary>
        internal static string GetProjectOwnerEmailAddresses (string projectName, string areaPath)
        {                                               
            string projectOwnerAddresses;

            switch (projectName)
            {
                case "Project 1":

                    projectOwnerAddresses = ProjectOwnerEmail.Project1;
                    break;

                case "Project 2":

                    projectOwnerAddresses = ProjectOwnerEmail.Project2;
                    break;

                case "Project 3":

                    projectOwnerAddresses = ProjectOwnerEmail.Project3;
                    break;

                default:
                    projectOwnerAddresses = ProjectOwnerEmail.Default;
                    break;
            }

            Logger.Log ("Project owner email addresses: " + projectOwnerAddresses);
            return projectOwnerAddresses;
        }
    }
}